package main

import (
	"fmt"
	"unsafe"
)

func main() {
	var i int = 1
	fmt.Println("i=", i)
	//测试int8的取值范围
	var j int8 = -128 //this is ok
	//	var j int8 = -129 //this is wrong constant -129 overflows int8
	fmt.Println("j=", j)
	var k uint8 = 255 //this is ok
	//	var k uint8 = 256//this is ok constant 256 overflows uint8
	fmt.Println("k=", k)
	//int uint 的范围限制和操作系统有关如果操作系统是64位，则数值范围同int64以及uint64

	/**
	使用细节
	*/
	var n1 = 100 //n1的数据类型
	fmt.Printf("n1 的类型是 %T \n", n1)
	//获取类型以及长度
	var n2 int64 = 10
	fmt.Printf("n2的数据类型是 %T  n2占用的字节数是 %d", n2, unsafe.Sizeof(n2))
	//尽量声明占用空间较小的变量
	//var age int8 = 150
}
